<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Title</title>
</head>
<body>
<?php
    //需要把所有的employee数据都获取到，然后通过一个表格输出到客户端
    header("Content-Type:text/html; charset=utf-8");
         //建立数据库连接，
        $con = mysqli_connect("127.0.0.1","root","","xxy");
        //判断是否已经建立链接
        if(!$con){
            printf("Can't connect to MySQL Server. Errorcode: %s ",mysqli_connect_error());
            exit;
        }
        $sql = "SELECT * FROM employee";
        //响应一个结果
        $result = mysqli_query($con,$sql);
        $list = array();
        //获取这个结果
        while($row = mysqli_fetch_array($result)){
            //怎么拿到数据
            //$row代表的是一行数据
            $item = array(
                "id" =>  $row["id"],
                "username" => $row["username"],
                "password" => $row["password"],
                "loginName" => $row["loginName"]
            );
            //往数组$list里面添加一条记录
            array_push($list,$item);
        }

        var_dump($list);

        //关闭连接
        mysqli_close($con);



?>
<table>
    <tr>
        <td>id编号</td>
        <td>用户名</td>
        <td>登录名</td>
        <td>密码</td>
    </tr>
    <?php
        for($i=0;$i<count($list);$i++){ ?>
            <tr>
                <td><?php echo $list[$i]["id"]; ?></td>
                <td><?php echo $list[$i]["username"]; ?></td>
                <td><?php echo $list[$i]["password"]; ?></td>
                <td><?php echo $list[$i]["loginName"]; ?></td>
            </tr>
    <?php } ?>
</table>
</body>
</html>